<template>
  <div>
    <div class="modal-header">
      <div class="modal-title">{{ title }}{{ rdoId }}</div>
    </div>

    <div class="modal-body">
      <g-model-audit-history-table
        :entityInfo="entityInfo"
        :parentData="parentData"
      ></g-model-audit-history-table>
    </div>

    <div class="modal-footer">
      <a-button @click="close">{{ l('Close') }}</a-button>
    </div>
  </div>
</template>

<script>
  import { ModalComponentBase } from '/@/shared/component-base';
  import GModelAuditHistoryTable from '/@/shared/components/g-model-audit-history-table/index.vue';
  export default {
    name: 'g-model-audit-history-view',
    mixins: [ModalComponentBase],
    components: {
      GModelAuditHistoryTable,
    },
    data() {
      return {
        title: '',
        rdoId: '',
        entityType: '',
        entityInfo: {},
        parentData: [
          {
            key: '1',
            firstName: 'John',
            lastName: 'Brown',
            age: 32,
            address: 'New York No. 1 Lake Park',
            tags: ['nice', 'developer'],
            expand: false,
            children_data: [
              {
                key: '01',
                firstName: 'John',
                lastName: 'Brown',
                age: 32,
                address: '66666',
                tags: ['nice', 'developer'],
                showHeader: false,
                norefash: false,
                children_data: [
                  {
                    key: '001',
                    firstName: 'John',
                    lastName: 'Brown',
                    age: 32,
                    address: '677777',
                    tags: ['nice', 'developer'],
                    expand: false,
                  },
                  {
                    key: '002',
                    firstName: 'Jim',
                    lastName: 'Green',
                    age: 42,
                    address: 'London No. 1 Lake Park',
                    tags: ['loser'],
                  },
                  {
                    key: '003',
                    firstName: 'Joe',
                    lastName: 'Black',
                    age: 32,
                    address: 'Sidney No. 1 Lake Park',
                    tags: ['cool', 'teacher'],
                  },
                ],
              },
              {
                key: '02',
                firstName: 'Jim',
                lastName: 'Green',
                age: 42,
                address: 'London No. 1 Lake Park',
                tags: ['loser'],
                norefash: false,
                showHeader: true,
                children_data: [
                  {
                    key: '001',
                    firstName: 'John',
                    lastName: 'Brown',
                    age: 32,
                    address: '677777',
                    tags: ['nice', 'developer'],
                    expand: false,
                  },
                  {
                    key: '002',
                    firstName: 'Jim',
                    lastName: 'Green',
                    age: 42,
                    address: 'London No. 1 Lake Park',
                    tags: ['loser'],
                  },
                  {
                    key: '003',
                    firstName: 'Joe',
                    lastName: 'Black',
                    age: 32,
                    address: 'Sidney No. 1 Lake Park',
                    tags: ['cool', 'teacher'],
                  },
                ],
              },
              {
                key: '03',
                firstName: 'Joe',
                lastName: 'Black',
                age: 32,
                address: 'Sidney No. 1 Lake Park',
                tags: ['cool', 'teacher'],
              },
            ],
          },
          {
            key: '2',
            firstName: 'Jim',
            lastName: 'Green',
            age: 42,
            address: 'London No. 1 Lake Park',
            tags: ['loser'],
          },
          {
            key: '3',
            firstName: 'Joe',
            lastName: 'Black',
            age: 32,
            address: 'Sidney No. 1 Lake Park',
            tags: ['cool', 'teacher'],
          },
        ],
      };
    },
    created() {
      // 实体名称
      const lastIndex = this.entityType.lastIndexOf('.') + 1;
      const entityType = this.entityType.substr(lastIndex, this.entityType.length - lastIndex);

      this.title = `${this.l('ModelAudit')} - ${this.l(entityType)}`;

      this.entityInfo = {
        id: this.rdoId,
        type: this.entityType,
      };
    },
    watch: {
      entityType(newVal) {
        console.log(newVal);
        // 实体名称
        const lastIndex = newVal.lastIndexOf('.') + 1;
        const entityType = newVal.substr(lastIndex, newVal - lastIndex);
        this.title = `${this.l('ModelAudit')} - ${this.l(entityType)}`;
      },
    },
    methods: {},
  };
</script>
